// ==============================================
// =      U.A.V.P Brushless UFO Controller      =
// =           Professional Version             =
// = Copyright (c) 2007 Ing. Wolfgang Mahringer =
// = Ported 2008 to 18F2520 by Ing. Greg Egan   =
// ==============================================
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License along
//  with this program; if not, write to the Free Software Foundation, Inc.,
//  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// ==============================================
// =  please visit http://www.uavp.org          =
// =               http://www.mahringer.co.at   =
// ==============================================

// Program Mode

#include "c-ufo.h"
#include "bits.h"

// read the current parameter set into the RAM variables
void ReadEEdata(void) // 245 uSec @ 16MHz
{
	int *p;
	Beeper_ON;
	
	if( IK5 > _Neutral_In )
		EEADR = _EESet2;	// user selected 2nd parameter set
	else
		EEADR = _EESet1;	// default 1st parameter set

	for(p = &FirstProgReg; p <= &LastProgReg; p++)
	{
		EEPGD = 0;
		RD = 1;
		*p = EEDATA;
		EEADR++;
	}

	BatteryVolts = LowVoltThres;

// Sanity check
// Limit the PWM output pause to between 1 and 30 ms
	if( Interval_time < 1 )
		Interval_time = 1;
	else
	if ( Interval_time > 30 )
		Interval_time = 30;
	//Beeper_OFF;
}

